package handler

import (
	"context"

	"github.com/micro/go-log"

	flow "gitee.com/yungrun/project/svr/flow/proto/flow"
)

type Flow struct{}

// Call is a single request handler called via client.Call or the generated client code
func (e *Flow) Create(ctx context.Context, req *flow.Request, rsp *flow.Response) error {
	log.Log("Received Flow.Create request")
	rsp.Id = req.Id
	rsp.Name = req.Name
	rsp.Remark = req.Remark
	rsp.Owner = req.Owner
	log.Log("create flow --->", rsp)
	return nil
}

func (e *Flow) Delete(ctx context.Context, req *flow.Request, rsp *flow.Response) error {
	log.Log("Received Flow.Delete request")
	log.Log("delete flow --->", req)
	rsp.Remark = "delete success"
	return nil
}

// Stream is a server side stream handler called via client.Stream or the generated client code
func (e *Flow) Query(ctx context.Context, req *flow.Request, rsp *flow.Response) error {
	log.Log("Received Flow.Query request")
	log.Log("query flow --->", req)

	rsp.Id = "2"
	rsp.Name = "project approve"
	rsp.Remark = "cet permission"
	rsp.Owner = "admin"
	return nil
}
